/**
 * @file:          MotorRippleTableCalibrator.h
 * @brief:         
 * @details:       
 * @author:        wjh
 * @date created:  2023.12.15
 * @version:       1.0.0
 * @par copyright (c):
 *   
 * @par history (desc):
 *   version:1.0.0, wjh, 2023.12.15,10:58:59
 */


#ifndef _MOTORRIPPLETABLECALIBRATOR_H_
#define _MOTORRIPPLETABLECALIBRATOR_H_

/* Include Files **************************************************************/
#include "common.h"
#include "Datatype.h"

/* Macro Definition ***********************************************************/
enum MotorRippleTableCalibratorProgress{
    MotorRippleTableCalibratorProgress_Init = 0,
    MotorRippleTableCalibratorProgress_ForwardRotation = 1,
    MotorRippleTableCalibratorProgress_ForwardRotationDelay = 2,
    MotorRippleTableCalibratorProgress_ForwardRotationSample = 3,
    MotorRippleTableCalibratorProgress_BackwardRotation = 4,
    MotorRippleTableCalibratorProgress_BackwardRotationDelay = 5,
    MotorRippleTableCalibratorProgress_BackwardRotationSample = 6,
    MotorRippleTableCalibratorProgress_Finished = 7,
    
};

/* Data Type Define ***********************************************************/
typedef struct MotorRippleTableCalibrator
{
    /* public data */
    /* use */
    uint16_t param_en;

    /* calibaration */
    uint16_t param_calibration_en;
    uint16_t param_cal_table_size;
    uint16_t param_sample_times_per_pos;
    uint16_t param_delay_period;
    float param_speed_step;

    int32_t pos_interval;
    float pos_step_accumulate;
    int32_t procedure;
    int32_t pos_step_encoder;
    int32_t pos_accumulate_encoder;
    float pos_rad;
    int32_t initial_pos_encoder;
    int32_t pos_encoder;
    int16_t run_dir;
    uint16_t tick_sample;
    uint16_t tick_delay;
    uint16_t pos_index;
    int32_t pos_encoder_sum;
    float cur_A_sum;
    int32_t pos_encoder_landmark;
    int32_t *pos_encoder_buff;
    float *cur_A_buff;

    
    /* private data */
    
    /* public method */
    void (*Init)(struct MotorRippleTableCalibrator *self);
    float (*Run)(struct MotorRippleTableCalibrator *self);
    
    /* private method */
    
}MotorRippleTableCalibrator;
    
/* Variable Declare ***********************************************************/

/* Function Declare ***********************************************************/
void MotorRippleTableCalibrator_Init(struct MotorRippleTableCalibrator *self);
float MotorRippleTableCalibrator_Run(struct MotorRippleTableCalibrator *self);


#endif